package casbinApi

import (
	"github.com/Sir-yuChen/funAnalyse/model"
	"github.com/Sir-yuChen/funAnalyse/model/common/response"
	"github.com/Sir-yuChen/funAnalyse/model/request"
	"github.com/Sir-yuChen/funAnalyse/utils"
	"github.com/gin-gonic/gin"
	"github.com/gin-gonic/gin/binding"
)

type StockCasbinRoleRelationResourcesController struct{}

// AssigningResources 分配资源
// @Summary AssigningResources get
// @Tags casbin
// @Accept application/json
// @Produce application/json
// @Param data body model.StockCasbinRoleRelationResourcesModel true "请求参数"
// @response 200 {object} response.Response  "接口返回信息"
// @Router /funAnalyse/casbin/AssigningResources [GET]
func (b *StockCasbinRoleRelationResourcesController) AssigningResources(c *gin.Context) {
	var req request.AssigningResourcesRequest
	err := c.ShouldBindBodyWith(&req, binding.JSON)
	if err != nil {
		utils.ErrValidatorResp(err, "AssigningResources", req, c)
		return
	}
	apiReturn := stockCasbinRoleRelationResourcesService.AssigningResources(&req, c)
	response.WithApiReturn(apiReturn, c)
	return
}

// GetStockCasbinRoleRelationResources 多条件查询
// @Summary stockCasbinRoleRelationResources get
// @Tags casbin
// @Accept application/json
// @Produce application/json
// @Param data body model.StockCasbinRoleRelationResourcesModel true "请求参数"
// @response 200 {object} response.Response  "接口返回信息"
// @Router /funAnalyse/casbin/getCasbinRoleRelationResources [GET]
func (b *StockCasbinRoleRelationResourcesController) GetStockCasbinRoleRelationResources(c *gin.Context) {
	var req model.StockCasbinRoleRelationResourcesModel
	err := c.ShouldBindJSON(&req)
	if err != nil {
		utils.ErrValidatorResp(err, "GetStockCasbinRoleRelationResources", req, c)
		return
	}
	apiReturn := stockCasbinRoleRelationResourcesService.GetStockCasbinRoleRelationResources(&req)
	response.WithApiReturn(apiReturn, c)
	return
}

// InsertStockCasbinRoleRelationResources
// @Summary stockCasbinRoleRelationResources insert
// @Tags casbin
// @Accept application/json
// @Produce application/json
// @Param data body model.StockCasbinRoleRelationResourcesModel true "请求参数"
// @response 200 {object} response.Response  "接口返回信息"
// @Router /funAnalyse/casbin/insertCasbinRoleRelationResources [POST]
func (b *StockCasbinRoleRelationResourcesController) InsertStockCasbinRoleRelationResources(c *gin.Context) {
	var req model.StockCasbinRoleRelationResourcesModel
	err := c.ShouldBindBodyWith(&req, binding.JSON)
	if err != nil {
		utils.ErrValidatorResp(err, "InsertStockCasbinRoleRelationResources", req, c)
		return
	}
	apiReturn := stockCasbinRoleRelationResourcesService.InsertStockCasbinRoleRelationResources(&req)
	response.WithApiReturn(apiReturn, c)
	return
}

// UpdateStockCasbinRoleRelationResources
// @Summary stockCasbinRoleRelationResources update
// @Tags casbin
// @Accept application/json
// @Produce application/json
// @Param data body model.StockCasbinRoleRelationResourcesModel true "请求参数"
// @response 200 {object} response.Response  "接口返回信息"
// @Router /funAnalyse/casbin/updateCasbinRoleRelationResources [POST]
func (b *StockCasbinRoleRelationResourcesController) UpdateStockCasbinRoleRelationResources(c *gin.Context) {
	var req model.StockCasbinRoleRelationResourcesModel
	err := c.ShouldBindBodyWith(&req, binding.JSON)
	if err != nil {
		utils.ErrValidatorResp(err, "UpdateStockCasbinRoleRelationResources", req, c)
		return
	}
	apiReturn := stockCasbinRoleRelationResourcesService.UpdateStockCasbinRoleRelationResources(&req)
	response.WithApiReturn(apiReturn, c)
	return
}

// DelStockCasbinRoleRelationResources
// @Summary stockCasbinRoleRelationResources del
// @Tags casbin
// @Accept application/json
// @Produce application/json
// @Param data body model.StockCasbinRoleRelationResourcesModel true "请求参数"
// @response 200 {object} response.Response  "接口返回信息"
// @Router /funAnalyse/casbin/delCasbinRoleRelationResources [Get]
func (b *StockCasbinRoleRelationResourcesController) DelStockCasbinRoleRelationResources(c *gin.Context) {
	var req model.StockCasbinRoleRelationResourcesModel
	err := c.ShouldBindBodyWith(&req, binding.JSON)
	if err != nil {
		utils.ErrValidatorResp(err, "DelStockCasbinRoleRelationResources", req, c)
		return
	}
	apiReturn := stockCasbinRoleRelationResourcesService.DelStockCasbinRoleRelationResources(&req)
	response.WithApiReturn(apiReturn, c)
	return
}
